package com.example.rbacmanage.service.system.impl;

import com.example.rbacmanage.entity.system.RoleDept;
import com.example.rbacmanage.mapper.system.RoleDeptMapper;
import com.example.rbacmanage.service.system.RoleDeptService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class RoleDeptServiceImpl implements RoleDeptService {

    @Autowired
    private RoleDeptMapper roleDeptMapper;

    @Override
    public void save(RoleDept roleDept) {
        roleDeptMapper.insert(roleDept);
    }

    @Override
    public void remove(Long[] ids) {
        for (Long id:ids){
            roleDeptMapper.del(id);
        }
    }

    @Override
    public void update(RoleDept roleDept) {
        roleDeptMapper.update(roleDept);
    }

    @Override
    public List<RoleDept> getAll(RoleDept roleDept) {
        return roleDeptMapper.list(roleDept);
    }

    @Override
    public PageInfo<RoleDept> getPage(RoleDept roleDept) {
        PageHelper.startPage(roleDept.getPage(),roleDept.getLimit());
        return new PageInfo<>(roleDeptMapper.list(roleDept));
    }

    @Override
    public RoleDept getById(Long id) {
        return roleDeptMapper.queryOneById(id);
    }

    @Override
    public Integer getCount(RoleDept roleDept) {
        return roleDeptMapper.count(roleDept);
    }
}
